package my.app.taxi;

import my.app.R;
import my.app.ServiceClient;
import android.content.Context;
import android.util.AttributeSet;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class TaxiRowView extends RelativeLayout{
	
	TextView phone = null;
	Context context = null;
	AttributeSet attrs = null;
	Taxi taxi = null;

	public TaxiRowView(Context context, AttributeSet attrs, Taxi t) {
		super(context, attrs);
		this.context = context;
		this.attrs = attrs;
		this.taxi = t;
		LayoutInflater layInf = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View view = layInf.inflate(R.layout.taxi_list_row, this);
		
		//Set Comp image...
		ImageView im = (ImageView) view.findViewById(R.id.taxi_list_cabicon);
		im.setImageResource(ServiceClient.getDrawableId(t.getCompIcon()));
		
		//Set Comp name...
		TextView tvc = (TextView) view.findViewById(R.id.taxi_list_company);
		tvc.setText(t.getLicenceTag());
		
		//Set Phone Number..
		TextView tvp = (TextView) view.findViewById(R.id.taxi_list_phone);
		tvp.setText(t.getTel());
		
		//Set Ratings..
		ImageView im2 = (ImageView) findViewById(R.id.taxi_list_stars_image);
		im2.setImageResource(ServiceClient.getDrawableId(t.getRating().toString()));
		
		//Set Ratings Count..
		TextView tvr = (TextView) findViewById(R.id.taxi_list_rating_count);
		tvr.setText("("+t.getRatingCount().toString()+" Ratings"+")");
	}
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		
		
		TaxiDialog t = new TaxiDialog(context, taxi);
		t.show();
		
		return super.onTouchEvent(event);
	}
	
	

	
	

}
